<?php 

	$name 			= $this->formText('name',str_replace("\\","",$this->Item['name']),array('class'=>'txtmedium'));
	$alias 			= $this->formText('alias',str_replace("\\","",$this->Item['alias']),array('class'=>'txtmedium'));
	$alt_seo 		= $this->formText('alt_seo',str_replace("\\","",$this->Item['alt_seo']),array('class'=>'txtmedium'));
	$title_seo 		= $this->formText('title_seo',str_replace("\\","",$this->Item['title_seo']),array('class'=>'txtmedium'));
	$picture 		= $this->formFile('picture1',array('style'=>'width: 250px'));
	$price 			= $this->formText('price',$this->Item['price'],array('class'=>'txtmedium','style'=>'width: 194px'));
	$selloff 		= $this->formText('selloff',$this->Item['selloff'],array('class'=>'txtmedium','style'=>'width: 194px'));
	$summary        = $this->formTextarea('summary',str_replace("\\","",$this->Item['summary']),array('rows'=>'10'));
	$description_html 	= $this->formTextarea('description_html',str_replace("\\","",$this->Item['description_html']),array('rows'=>'10'));									
	$keywords_html 		= $this->formTextarea('keywords_html',str_replace("\\","",$this->Item['keywords_html']),array('rows'=>'10'));	
	$GroupCategory = $this->cmsSelect('menu_id',$this->Item['menu_id'],$this->tblGroupCategory,
										array('style'=>'width:200px','size'=>10));
	$content		= $this->cmsReplaceString($this->Item['content']);
	$content		= $this->cmsEditor('content',str_replace("\\","",$content),array('toolbar'=>'Default','language'=>'vi'));
	
	$options 	= array($this->translate('Inactive'),$this->translate('Active'));
	$status 	= $this->formRadio('status',$this->Item['status'],null,$options, ' ');
	
	$options 	= array($this->translate('No'),$this->translate('Yes'));
	$special 	= $this->formRadio('special',$this->Item['special'],null,$options, ' ');
	
	$options 	= array($this->translate('No'),$this->translate('Yes'));
	$featured 	= $this->formRadio('featured',$this->Item['featured'],null,$options, ' ');
	
	/*...........Picture............*/
	$imgArr 		= !empty($this->Item['picture'])?array( FILES_URL . '/products/images100x100/'.$this->Item['picture']):'';
	$image 	= $this->cmsUserAvatar($inputInfo, $imgArr);
	if(!empty($this->Item['picture'])){
	  	$urlimage   = FILES_URL . '/products/images100x100/'. $this->Item['picture'];
	  	$imgimage  = '<span><img src="' . $urlimage . '" width="" height="40"></span>'; 
	  	$picture  = $imgimage ."<br/>" . $this->formFile('picture1',array('style'=>'margin-left:173px'));	
	}else{
		$picture  = $this->formFile('picture1',array('style'=>'margin-left:5px'));
	}
 	$current_stadium = $this->formHidden('current_stadium_picture',$this->Item['picture']);  
	
	$Input = array(
					array('Label'=>$this->translate('Product name'),'input'=>$name,'info'=>0),
					array('Label'=>$this->translate('Alias'),'input'=>$alias,'info'=>0),
					array('Label'=>$this->translate('Picture'),'input'=>$picture,'info'=>0),
					array('Label'=>$this->translate('Alt SEO'),'input'=>$alt_seo,'info'=>0),
					array('Label'=>$this->translate('Title SEO'),'input'=>$title_seo,'info'=>0),
					array('Label'=>$this->translate('Price'),'input'=>$price,'info'=>0),
					array('Label'=>$this->translate('Sale Off'),'input'=>$selloff,'info'=>0),
					array('Label'=>$this->translate('Category'),'input'=>$GroupCategory,'info'=>0),
					array('Label'=>$this->translate('Status'),'input'=>$status,'info'=>0),
					array('Label'=>$this->translate('Special'),'input'=>$special,'info'=>0),
					array('Label'=>$this->translate('Featured'),'input'=>$featured,'info'=>0),
                    array('Label'=>$this->translate('Summary'),'input'=>$summary,'info'=>0),
                    array('Label'=>$this->translate('Description HTML'),'input'=>$description_html,'info'=>0),
					array('Label'=>$this->translate('Keywords HTML'),'input'=>$keywords_html,'info'=>0),
					array('Label'=>$this->translate('Content'),'input'=>$content,'style'=>'margin-left:174px'),
					);
	if(count($this->errors)>0){
		$errors = $this->formErrors($this->errors,array('id'=>'errors'));
	}
?>
<form name="appForm" method="post" action="" enctype="multipart/form-data">

                        <?php echo $this->render('toolbar.php')?>
                        <div class="clr"></div>
                        <?php echo $this->render('sublink.php')?>
                        <?php echo $errors;?>

                        <!-- BEGIN: CONTENT -->
                        <div id="element-box">
                            <div class="t">
                                <div class="t">
                                    <div class="t"></div>
                                </div>
                            </div>
                            <div class="m">
                                <!-- BEGIN: ELEMENT BOX -->
						<div id="adminfieldset">
                             <div class="adminheader"><?php echo $this->translate('Information')?></div>								
								<?php echo $this->partialLoop('rows.php',$Input) . $current_stadium ;?>  
								
								
								
								
								
								<div id="row-upload" style="margin-left:180px;margin-top:15px">
								<input id="file_upload" name="file_upload" type="file" multiple="true">
							</div>
							
							<div id="show-img">
								
<!-- 								<div class="img-row"> -->
<!-- 									<input type="hidden" name="picture[]" value="file_a.jpg"> -->
									<!-- <img width="100" height="100" src="<?php //echo FILES_URL."/photos/images200x200/1353578797_Penguins.jpg" ?>"/> -->
<!-- 									<span class='img-del' id='flie_a.jpg'>xóa<span> -->
<!-- 								</div> -->
								
								<?php 
								
								if($this->the_action=='edit')
								{ 
									$thiss->Item['id'];
									$mod=new Zendvn_Models_ProductsPictures();
									$items=$mod->listItem(array('p_id'=>$this->Item['id']),array('task'=>'public-list'));
									if(count($items) >0)foreach ($items as $item)
									{
										$pic=$item['img'];
										$id=$item['id'];
								?>
								<div class="img-row">
									<input type="hidden" name="picture[]" value="<?php echo $pic ?>">
									<img width="100" height="100" src="<?php echo FILES_URL."/products/images450x450/$pic" ?>"/>
									<span class="img-del" id="<?php echo $id ?>" title="<?php echo $pic ?>">xóa</span>
								</div>
								<?php }
								} ?>
								
							</div>
							<script type="text/javascript">
							 		$(".img-del").live('click',function(){
										 var id=$(this).attr('id');
										 var img=$(this).attr('title');
										 var datas='img='+img+'&id='+id;
										 $.ajax
										 ({
											type:'post',
											url :'<?php echo $this->baseUrl("/products/admin-product/ajax") ?>',
											data:datas,
											success:function()
											{
													
											}
										 });

										 $(this).parents("div:first").remove();	
											
												 
								 	});								 							 
							</script>	
								
								
								
								                              
							</div>
							
                                <!-- END: ELEMENT BOX -->	
                              <div class="clr"></div>
                            </div>
                            <div class="b">
                                <div class="b">
                                    <div class="b"></div>
                                </div>
                            </div>
                        </div>
                        <!-- END: 	CONTENT -->
                    </form>
                    
<script type="text/javascript">
		<?php $timestamp = time();?>
		$(function() {
			$('#file_upload').uploadify({
				'formData'     : {
					'timestamp' : '<?php echo $timestamp;?>',
					'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
				},
				'fileSizeLimit' : '1000KB',
				'fileTypeDesc' : 'Image Files',
				'fileTypeExts' : '*.gif; *.jpg; *.png ; *.jpeg',
				'swf'      : '<?php echo PUBLIC_URL.'/uploadify/uploadify.swf' ?>',
				'uploader' : '<?php echo PUBLIC_URL.'/uploadify/uploadifyProducts.php' ?>',
				'onUploadSuccess' : function(file, data, response)
				{
					$("#show-img").prepend(data);
				}
				
			});
		});
</script>                    